<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript">
$(document).ready(function(){
	
	$("#writeBtn").on("click",function(){
		var title = $("#title").val();
		if(title==""){
			alert("제목을 입력해주세요.");
			return;
		}
		
		var content = $("#content").val();
		if(content==""){
			alert("내용를 입력해주세요.");
			return;
		}
		
		var flag=confirm("수정 하시겠습니까?");
		
		 if(flag){
			 var f = $("#update_form");
			 f.submit();
		 }
	});
});
</script>

<c:choose>
	<c:when test="${sessionScope.mvo.uId==null || requestScope.bvo.memberVO.uId!=sessionScope.mvo.uId}">
		<script type="text/javascript">
			alert("ㄱㅎㄴ ㅁㄹ!");
			location.href="${initParam.root }/index.jsp";
		</script>
	</c:when>
	<c:otherwise>
<h3>글수정</h3>

  <form action="${initParam.root }/board.do" method="post" id="update_form">
  <input type="hidden" name="mode" value="update">
  <input type="hidden" name="no" value="${param.no }">
   <table width="70%" >
   
    <tr>
     <td width="10%">제목</td>
     	<td colspan="3">
    	 <input type="text" id="title" maxlength="200" size="50" name="title" value="${requestScope.bvo.title }">
     </td>
    </tr>
    
	<tr>
		<td width="20%">작성일시</td><td width="30%">${requestScope.bvo.w_data }</td>
	</tr>
	
    <tr>
     <td colspan="4">
     	<textarea cols="80" rows="20" id="content" name="contents">${requestScope.bvo.contents}</textarea>
     </td>
    </tr> 
    
    <tr>
     <td colspan="2" align="right">
     	<input type="button" id="writeBtn" value="수정하기">
     </td>
    </tr>
    
   </table>
   
  </form>
    </c:otherwise>
</c:choose>
